package com.linghang.lhonline.service.Impl;

import com.linghang.lhonline.dataobject.Mission;
import com.linghang.lhonline.repository.MissionRepository;
import com.linghang.lhonline.service.MissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MissionServiceImpl implements MissionService {

    private MissionRepository missionRepository;

    @Autowired
    public MissionServiceImpl(MissionRepository missionRepository) {
        this.missionRepository = missionRepository;
    }

    @Override
    public Mission save(Mission mission) {
        return missionRepository.save(mission);
    }

    @Override
    public void delete(Integer missionId) {
        Mission mission = missionRepository.findByMissionId(missionId);
        missionRepository.delete(mission);
    }

    @Override
    public Mission findByMissionId(Integer missionId) {
        return missionRepository.findByMissionId(missionId);
    }

    @Override
    public List<Mission> findByGroupName(String groupName) {
        return missionRepository.findByGroupName(groupName);
    }
}
